//
// Created by Sugars Mac on 2020/5/27.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <netinet/in.h>
#include "../Datars.h"

void testProcessUserInput(){
    users[0].sockfd = STDIN_FILENO;
    char buf[BUFFSIZE];

    int ret = -1;
    while (ret != DISC) {
        ret = processUserInput(0, buf);
        printf("read %lu bytes:%s", strlen(buf), buf);
        printf("the user type : %d\n", ret);
    }
}

int main(int argc, char* argv[]){
//    testProcessUserInput();
    char input[20] = "[TO] Ben pass";
    char buf[20];
    char * p = strtok(input, " "); // 此时p指向"[TO]"
    printf("strlen(p) = %lu, p = %s\n", strlen(p), p);
    p = strtok(NULL, " "); // 此时p指向"Ben"
    printf("strlen(p) = %lu, p = %s\n", strlen(p), p);
    p = strtok(NULL, " "); // 此时p指向"pass"
    printf("strlen(p) = %lu, p = %s\n", strlen(p), p);
    p = strtok(NULL, " "); // 此时p指向"Ben"
    printf("p == NULL : %d\n", p==NULL);
//    // strcpy(buf, "Hello ");
//    strcat(buf, p);
//    printf("len of %s : %lu\n", buf, strlen(buf));
//    printf("the original string: %s\n", input);

//    while(p){
//        printf("strlen = %lu, %s\n", strlen(p), p);  // 获取剩余的分割
//        p = strtok(NULL, " ");
//    }
    return 0;
}